home *** CD-ROM | disk | FTP | other *** search
- /* Arexx script to help people with Snap arguments */
-
- signal on error
-
- if ~show('l', "rexxarplib.library") then do
- check = addlib('rexxsupport.library',0,-30,0)
- check = addlib('rexxmathlib.library',0,-30,0)
- check = addlib('rexxarplib.library',0,-30,0)
- end
-
- if ~exists("fonts:helvetica/15") then do
- say "I need font 'Helvetica 15'."
- exit 10
- end
-
- bool.0 = 'OFF'; bool.1 = 'ON'
-
- /* Fix window dimensions */
-
- screen.width = ScreenCols()
- screen.height = ScreenRows()
-
- window.width = 400
- window.height = 200
- window.leftedge = (screen.width-window.width)/2
- window.topedge = (screen.height-window.height)/2
-
- /* Set up a host */
- parse version 'V' vers .
- signal on syntax
- call stop(SNAPHOST)
- syntax:
- if vers > 1.06 then
- address AREXX "'call CreateHost(SNAPHOST, SNAPPORT)'"
- else
- "runwsh >nil:" "'call CreateHost(SNAPHOST, SNAPPORT)'"
-
- /*
- * Wait for a while until host is ready.
- */
- do for 50 while ~show('Ports','SNAPHOST')
- call delay 10 /* 200 ms */
- end
-
- call SetReqColor(SNAPHOST, BLOCKPEN, 1)
- call SetReqColor(SNAPHOST, DETAILPEN, 0)
-
- /*
- * Open the window
- */
- window.idcmp = 'CLOSEWINDOW+GADGETUP+RAWKEY'
- window.flags = 'WINDOWCLOSE+WINDOWDRAG+WINDOWDEPTH+ACTIVATE'
-
- title = "Setup tool for Snap"
- snap = show('P','Snap.port')
- if snap then
- title = title "(Snap is installed)"
- else
- title = title "(Snap is not installed)"
-
- call OpenWindow(SNAPHOST, window.leftedge, window.topedge, window.width, ,
- window.height, window.idcmp, window.flags, title)
-
- call ModifyHost(SNAPHOST, RAWKEY, "RAWKEY %c")
-
- call SetFont(SNAPHOST, "Helvetica.font", 15)
-
- signal dotext
- /* --- Start of texts ---
- 10
- " Please hold on..." 5 20 45 ""
- "Priority:" 5 40 6 "Input handler priority."
- "Insert key:" 215 60 9 "Key used with Left Amiga to insert."
- "Char delay:" 215 80 9 "Delay after each inserted character"
- "Line delay:" 215 100 9 "Delay after each inserted newline."
- "Bit mask:" 215 120 9 "Bit planes to draw selection frame into."
- "Starting unit:" 215 140 9 "Unit in which to start snapping."
- "Selection frame pattern:" 215 40 19 "Pattern used for crawling dots in selection frame."
- "Text qualifier:" 5 60 11 "Qualifier used when snapping characters."
- "Gfx qualifier:" 110 60 11 "Qualifier used when snapping graphics."
- --- End of texts --- */
-
- dotext:
- textlines = sigl+2
- parse value sourceline(textlines) with num .
-
- call SetReqColor(SNAPHOST, 'BOXPEN', 0)
- call SetReqColor(SNAPHOST, 'SHADOWPEN', 0)
- call SetAPen(SNAPHOST, 1)
- do i=1 for num
- parse value sourceline(textlines+i) with '"'text'"' x y w . '"'help'"'
- call AddGadget(SNAPHOST, x, y, 'HLP'i, copies(' ',w), "HELP "help)
- end
-
- call SetReqColor(SNAPHOST, 'BOXPEN', 2)
- call SetReqColor(SNAPHOST, 'SHADOWPEN', 3)
- do i=1 for num
- parse value sourceline(textlines+i) with '"'text'"' x y w . '"'help'"'
- call Move(SNAPHOST, x, y+10); call Text(SNAPHOST, text)
- end
-
- /* Set up some nice gadgets */
- x = 65
- do i=51 for 5
- call AddGadget(SNAPHOST, x, 40, 'PR'i, ''i'', 'PRIORITY 'i); x = x+27
- end
-
- ins.1 = 23; ins.2 = 15; ins.3 = 34
- key.1 = 'I'; key.2 = 'Y'; key.3 = 'V'
- x = 300
- do i=1 for 3
- call AddGadget(SNAPHOST, x, 60, 'INS'i, key.i, 'INSKEY 'i); x = x+20
- end
-
- x = 300
- do i=0 for 3
- call AddGadget(SNAPHOST, x, 80, 'CDL'i, i, 'CDELAY 'i); x = x+20
- end
-
- x = 300
- do i=0 for 3
- call AddGadget(SNAPHOST, x, 100, 'LDL'i, i, 'LDELAY 'i); x = x+20
- end
-
- x = 300
- do i=0 for 3
- call AddGadget(SNAPHOST, x, 120, 'MSK'i, i, 'MASK 'i); x = x+20
- end
-
- call AddGadget(SNAPHOST, 300, 140, 'UNT'0, "Frame", 'UNIT 0')
- call AddGadget(SNAPHOST, 300, 155, 'UNT'1, "Char ", 'UNIT 1')
-
- call SetReqColor(SNAPHOST, 'SHADOWPEN', 0L)
- y = 18
- do i=0 for 16
- call AddGadget(SNAPHOST, 380, y, 'PAT'i, ' ', 'PATTERN 'i); y = y+11
- end
- call SetReqColor(SNAPHOST, 'SHADOWPEN', 3L)
-
- bit.1 = 0; desc.1 = 'Left Shift '
- bit.2 = 1; desc.2 = 'Right Shift'
- bit.3 = 3; desc.3 = 'Control '
- bit.4 = 4; desc.4 = 'Left Alt '
- bit.5 = 5; desc.5 = 'Right Alt '
- bit.6 = 6; desc.6 = 'Left Amiga '
- bit.7 = 7; desc.7 = 'Right Amiga'
-
- y = 75
- do i=1 for 7
- call AddGadget(SNAPHOST, 5, y, 'TQ'i, desc.i, 'TEXTQUAL 'i)
- call AddGadget(SNAPHOST, 110, y, 'GQ'i, desc.i, 'GFXQUAL 'i)
- y = y+15
- end
-
- call AddGadget(SNAPHOST, 35, 180, 'XERX', 'Immediate insert', 'XEROX')
-
- call AddGadget(SNAPHOST, 235, 180, 'APPLY', 'Apply settings', 'APPLY')
-
- /* Open our host port */
- call openport(SNAPPORT)
-
- start:
-
- call ShowText(" Setting defaults...")
- pri = 51; call SetGadget(SNAPHOST, 'PR51', 'ON')
- textqual = '0040'x; call SetGadget(SNAPHOST, 'TQ6', 'ON')
- gfxqual = '0080'x; call SetGadget(SNAPHOST, 'GQ7', 'ON')
- inskey = 1; call SetGadget(SNAPHOST, 'INS1', 'ON')
- cdelay = 0; call SetGadget(SNAPHOST, 'CDL0', 'ON')
- ldelay = 0; call SetGadget(SNAPHOST, 'LDL0', 'ON')
- pattern = '7777'x;
- do i=0 for 16
- if bittst(pattern,i) then call SetGadget(SNAPHOST, 'PAT'i, 'ON')
- end
- xerox = 0
- unit = 0; call SetGadget(SNAPHOST, 'UNT0', 'ON')
- planes = '00'x
-
- call ShowText(" Select options. Click here for help.")
-
- help.1 = "Click text (eg 'Priority') for help. Click here for more help."
- help.2 = "Close window for correct command line. Click for more."
- help.3 = "Click 'Apply settings' to reconfigure Snap."
- maxhelp = 3
-
- keycmd. = ""
- keycmd.95 = "HELP"; keycmd.25 = "PRIORITY"; keycmd.16 = "CLOSEWINDOW"
- keycmd.23 = "INSKEY"; keycmd.51 = "CDELAY"; keycmd.40 = "LDELAY"
- keycmd.33 = "UNIT"; keycmd.32 = "APPLY"
-
- main:
- quitflag = 0
- helpnum = 1
-
- loop:
- if quitflag~=0 then signal done
-
- call waitpkt(SNAPPORT)
- p = getpkt(SNAPPORT)
- if p == NULL() then signal loop
-
- cmd = getarg(p)
- call reply(p, 0)
-
- docmd:
- parse var cmd item val .
- signal value item
-
- closewindow:
- quitflag = 1
- signal loop
-
- rawkey:
- cmd = keycmd.val
- if cmd ~= "" then do
- signal docmd
- end
- signal loop
-
- help:
- parse var cmd item help
- if help="" then do
- call showtext(help.helpnum)
- helpnum = helpnum+1
- if helpnum>maxhelp then helpnum = 1
- end
- else do
- call showtext(help)
- end
- signal loop
-
- priority:
- if val="" then do
- val = pri+1
- if val>55 then val = 51
- end
- pri = val
- do i=51 for 5
- call setgadget(SNAPHOST, 'PR'i, 'OFF')
- end
- call setgadget(SNAPHOST, 'PR'pri, 'ON')
- signal loop
-
- inskey:
- if val="" then do
- val = inskey+1
- if val>3 then val = 1
- end
- inskey = val
- do i=1 for 3
- call setgadget(SNAPHOST, 'INS'i, 'OFF')
- end
- call setgadget(SNAPHOST, 'INS'val, 'ON')
- signal loop
-
- cdelay:
- if val="" then do
- val = cdelay+1
- if val>2 then val = 0
- end
- cdelay = val
- do i=0 for 3
- call setgadget(SNAPHOST, 'CDL'i, 'OFF')
- end
- call setgadget(SNAPHOST, 'CDL'val, 'ON')
- signal loop
-
- ldelay:
- if val="" then do
- val = ldelay+1
- if val>2 then val = 0
- end
- ldelay = val
- do i=0 for 3
- call setgadget(SNAPHOST, 'LDL'i, 'OFF')
- end
- call setgadget(SNAPHOST, 'LDL'val, 'ON')
- signal loop
-
- unit:
- if val="" then do
- val = 1-unit
- end
- unit = val
- call setgadget(SNAPHOST, 'UNT0', 'OFF')
- call setgadget(SNAPHOST, 'UNT1', 'OFF')
- call setgadget(SNAPHOST, 'UNT'unit, 'ON')
- signal loop
-
- pattern:
- pattern = bitchg(pattern,val)
- temp = bittst(pattern,val)
- call setgadget(SNAPHOST, 'PAT'val, bool.temp)
- signal loop
-
- mask:
- planes = bitchg(planes,val)
- temp = bittst(planes,val)
- call setgadget(SNAPHOST, 'MSK'val, bool.temp)
- signal loop
-
- textqual:
- if bittst(textqual,bit.val) then do
- textqual = bitclr(textqual,bit.val)
- call setgadget(SNAPHOST, 'TQ'val, 'OFF')
- end
- else do
- call setgadget(SNAPHOST, 'GQ'val, 'OFF')
- gfxqual = bitclr(gfxqual,bit.val)
- textqual = bitset(textqual,bit.val)
- call setgadget(SNAPHOST, 'TQ'val, 'ON')
- end
- signal loop
-
- gfxqual:
- if bittst(gfxqual,bit.val) then do
- gfxqual = bitclr(gfxqual,bit.val)
- call setgadget(SNAPHOST, 'GQ'val, 'OFF')
- end
- else do
- call setgadget(SNAPHOST, 'TQ'val, 'OFF')
- textqual = bitclr(textqual,bit.val)
- gfxqual = bitset(gfxqual,bit.val)
- call setgadget(SNAPHOST, 'GQ'val, 'ON')
- end
- signal loop
-
- xerox:
- xerox = 1-xerox
- call setgadget(SNAPHOST, 'XERX', bool.xerox)
- signal loop
-
- apply:
- quitflag = 2
- signal loop
-
-
- done:
- if c2d(textqual)=0 then do
- call ShowText("No text qualifier specified!")
- signal main
- end
- else if c2d(gfxqual)=0 then do
- call ShowText("No graphics qualifier specified!")
- signal main
- end
-
- cmd = ""
- if pri~=51 then cmd = cmd "-p"pri
- if textqual~='0040'x then cmd = cmd "-t"c2x(textqual)
- if gfxqual~='0080'x then cmd = cmd "-g"c2x(gfxqual)
- if key.inskey~='I' then cmd = cmd "-i"ins.inskey
- if cdelay~=0 then cmd = cmd "-c"cdelay
- if ldelay~=0 then cmd = cmd "-l"ldelay
- if pattern~='7777'x then cmd = cmd "-a"c2x(pattern)
- if xerox then cmd = cmd "-x"
- if unit~=0 then cmd = cmd "-u"unit
- if planes~='00'x then cmd = cmd "-b"c2x(planes)
-
- snapcmd = "snap"
-
- if quitflag=1 then do
- say snapcmd || cmd
- end
- else do
- if ~exists("snap") & ~exists("c:snap") then do
- snapcmd = GetFile(50, 50, "sys:", "", "Find Snap for me")
- if word(statef(snapcmd),1) ~= 'FILE' then do
- snapcmd = snapcmd'snap'
- end
- end
- if exists(snapcmd) then do
- if snap then address command snapcmd cmd
- address command snapcmd cmd
- end
- else do
- call ShowText("Snap not found.")
- signal main
- end
- end
-
- error:
- call Stop(SNAPHOST)
- exit
-
- showtext: procedure expose SNAPHOST
-
- parse arg text
-
- call SetAPen(SNAPHOST, 0)
- call RectFill(SNAPHOST, 5, 15, 370, 35)
- call SetAPen(SNAPHOST, 1)
- call Move(SNAPHOST, 5, 30)
- call Text(SNAPHOST, text)
- return
-